package com.ytjj.qmyx.admin.controller.circle;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.utils.UserUtil;
import com.ytjj.qmyx.users.client.CircleClient;
import com.ytjj.qmyx.users.model.circle.CircleActivityDetailRequest;
import com.ytjj.qmyx.users.model.circle.CircleActivityInfoQueryRequest;
import com.ytjj.qmyx.users.model.circle.CircleActivityInfoRequest;
import com.ytjj.qmyx.users.model.circle.CircleActivityProductListRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 团活动管理
 * 1.创建团活动
 * 2.查询团活动信息
 */
@Slf4j
@RestController
@RequestMapping("/circleActivity")
public class CircleActivityInfoController {
    @Autowired
    private CircleClient circleClient;

    //1.创建团活动
    @PostMapping("/save")
    public CommonResult save(@Validated @RequestBody CircleActivityInfoRequest request) {
        request.setPlatFlag(1);
        request.setCreateUser(UserUtil.getAdminId());
        return circleClient.save(request);
    }

    //2.查询团购活动列表
    @PostMapping("/list")
    public CommonResult list(@RequestBody CircleActivityInfoQueryRequest request) {
        return circleClient.list(request);
    }

    /**
     * 3.查询团购活动详情
     * @param request
     * @return
     */
    @PostMapping("/detail")
    public CommonResult detail(@Validated @RequestBody CircleActivityDetailRequest request) {
        return circleClient.detail(request);
    }

    @PostMapping("/productList")
    public CommonResult productList(@Validated @RequestBody CircleActivityProductListRequest request) {
        return circleClient.productList(request);
    }

}
